//
// dataset_explorer control supporting js code
//

// kolais: this is a part of dataset explorer component; will go to relevant module
function
ep_de_change_current_root_dataset( selectable_actions, select_actions_by_epc_id )
    {
    var selection = document.getElementById("current_root_dataset_id");
    var xmlhttp = getXMLHTTP();
    if (xmlhttp)
        {
        var tree = document.getElementById("analysis_history_tree");
        tree.innerHTML = "Loading history...";

        var new_dataset_id = selection[selection.selectedIndex].value;
        xmlhttp.open
            ( "GET"
            , cgi_href
                + "/ep_change_current_root_dataset.pl?dataset_id="
                + new_dataset_id
                + "&now="
                + new Date()
                + "&selectable_actions="
                + selectable_actions
                + "&select_actions_by_epc_id="
                + select_actions_by_epc_id
            );
        xmlhttp.onreadystatechange = function ()
            {
            if ( xmlhttp.readyState == 4 && xmlhttp.responseText )
                {
                var r = xmlhttp.responseText.substring( 2, xmlhttp.responseText.indexOf("."));
                var s = document.getElementById("current_root_dataset_id");
                if ( r == s[s.selectedIndex].value )
                    {
                    try {
                        eval ( xmlhttp.responseText ); 
                        }
                    catch (e)
                        {
                        var tree = document.getElementById("analysis_history_tree");
                        tree.innerHTML = e.message;
                        }
                    }
                else
                    {
                    }
                }
            }
        xmlhttp.send(null);
        }
    }

function
ep_de_change_current_folder(folder_id)
    {
    document.mainfrm.active_component_id.value = "";
    if ( document.mainfrm.current_folder_id.value == folder_id )
        {
        return;
        }

    document.mainfrm.current_folder_id.value = folder_id;
    document.mainfrm.current_root_dataset_id.value = "";
    document.mainfrm.submit();
    }
